import { OAVComponent, AttributeViewInfo } from '@feng3d/objectview';
import { Spinner } from '../components/JQueryUI';
import { OAVDefault } from '../defaults/OAVDefault';

/**
 * 默认对象属性界面
 */
@OAVComponent()
export class OAVNumber extends OAVDefault
{
	fractionDigits = 3;

	// eslint-disable-next-line @typescript-eslint/ban-ts-comment
	// @ts-ignore
	attributeValue: number;

	spinner: Spinner;

	constructor(attributeViewInfo: AttributeViewInfo)
	{
		super(attributeViewInfo);

		this.spinner = new Spinner();
		this.addChild(this.spinner);
	}

	/**
	 * 更新界面
	 */
	updateView(): void
	{
		const pow = Math.pow(10, this.fractionDigits);
		const value = Math.round(this.attributeValue * pow) / pow;
		this.text.value = String(value);
	}
}
